<script setup lang="ts">
import { submitgetpage } from '@/services/home'
import { onLoad } from '@dcloudio/uni-app'
import { ref, reactive } from 'vue'

// 获取任务列表
const categoryList = ref<any>([])
const getHomeCategoryData = async () => {
  const currentPage = getCurrentPages().pop()
  const id = currentPage?.$page.options.id
  const res = await submitgetpage({ id: id })
  if (res.success) {
    categoryList.value = res.data.list
  }
}
const godetail = (id: number) => {
  uni.navigateTo({
    url: '/pagesMember/submitdetail/submitdetail?id=' + id,
  })
}

// 是否加载中标记
const isLoading = ref(false)

// 页面加载
onLoad(async () => {
  isLoading.value = true
  await Promise.all([getHomeCategoryData()])
  isLoading.value = false
})
</script>

<template>
  <view class="nosearch" v-if="!categoryList.length">
    <img src="@/static/images/nosearch.png" alt="" />
    <view class="">没有找到</view>
  </view>
  <view class="viewport" v-else>
    <scroll-view enable-back-to-top class="scroll-view" scroll-y>
      <view class="task" v-for="item in categoryList" :key="item.id">
        <view class="task-price">
          <view class=""><text style="color: #999">资料编号：</text>{{ item.id }}</view>
          <view class="price" v-if="item.status == 20">￥{{ item.price }}</view>
          <uni-tag :inverted="true" text="待处理" v-if="item.status == 10" />
          <uni-tag :inverted="true" text="已拒绝" type="error" v-if="item.status == 99" />
        </view>
        <view
          class=""
          style="
            margin-top: 20rpx;
            display: flex;
            align-items: center;
            justify-content: space-between;
          "
        >
          <view class=""
            ><text style="color: #999">提交时间：</text
            >{{ item.createdTime.substring(0, 16).replace(' ', ' ') }}</view
          >
          <view class=""
            ><text style="color: rgb(37, 131, 255)" @click="godetail(item.id)">查看详情</text></view
          >
        </view>
      </view>
    </scroll-view>
  </view>
</template>

<style lang="scss">
.nosearch {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 200rpx;
  img {
    height: 200rpx;
  }
  view {
    color: #999;
  }
}
.loading {
  text-align: center;
  margin-bottom: 10rpx;
  font-size: 24rpx;
}
.tasklist {
  background-color: #fff;
  padding: 26rpx;
  font-weight: bold;
  font-size: 32rpx;
}

page {
  background-color: #f7f7f7;
  height: 100%;
  overflow: hidden;
}

.task {
  background-color: #fff;
  margin: 20rpx;
  margin-bottom: 30rpx;
  padding: 30rpx;
  border-radius: 10rpx;
  font-size: 24rpx;
  .task-price {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30rpx;
    padding-bottom: 20rpx;
    border-bottom: 1px solid #eee;
    .price {
      font-size: 40rpx;
      color: red;
      font-weight: bold;
    }
  }
  .task-title {
    display: flex;
    flex-wrap: nowrap;
    margin-bottom: 30rpx;
    view {
      font-size: 28rpx;
      font-weight: bold;
      margin-left: 20rpx;
      color: #4d4d4d;
      word-break: break-all;
    }
    img {
      margin-top: 5rpx;
      height: 30rpx;
      width: 30rpx;
    }
  }
}

.viewport {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.scroll-view {
  flex: 1;
  overflow: hidden;
}

.button {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 140rpx;
  height: 50rpx;
  font-size: 28rpx;
  border-radius: 72rpx;
  color: #fff;
  background-color: #1e9fff;
}

.search {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0.9;
  padding: 0 10rpx 0 26rpx;
  height: 64rpx;
  margin: 16rpx 0;
  color: #999;
  font-weight: 500;
  font-size: 28rpx;
  border-radius: 32rpx;
  background-color: #f2f2f2;
}

.icon-search {
  &::before {
    margin-right: 10rpx;
  }
}
</style>
